<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户状态变更查询</title>
<link href="${rc.contextPath}/assets/css/bootstrap.min.css"
	rel="stylesheet" />

<link rel="stylesheet"
	href="${rc.contextPath}/assets/css/font-awesome.min.css" /><!-- 
<link rel="stylesheet"
	href="${rc.contextPath}/assets/css/datepicker.css" /> --><!-- 
<link rel="stylesheet"
	href="${rc.contextPath}/assets/css/daterangepicker.css" /> -->
<link rel="stylesheet" href="${rc.contextPath}/assets/css/ui.jqgrid.css" />

<link rel="stylesheet"
	href="${rc.contextPath}/assets/css/jquery-ui-1.10.3.full.min.css" />
<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace.min.css" />
<link href="${rc.contextPath}/common/css/common/commonnew.css"rel="stylesheet" type="text/css" />
<!-- ace settings handler -->
<script src='${rc.contextPath}/assets/js/jquery-2.0.3.min.js'></script>
<script src="${rc.contextPath}/assets/js/bootstrap.min.js"></script>
<!-- page specific plugin scripts -->

<script src="${rc.contextPath}/assets/js/jquery-ui-1.10.3.full.min.js"></script>
<script src="${rc.contextPath}/assets/js/jqGrid/jquery.jqGrid.min.js"></script>
<script src="${rc.contextPath}/assets/js/jqGrid/i18n/grid.locale-en.js"></script>
<!-- ace scripts --><!-- 
<script
	src="${rc.contextPath}/assets/js/date-time/bootstrap-datepicker.min.js"></script> -->
<script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
<!-- <script src="${rc.contextPath}/common/js/common.js"></script>
<script src="${rc.contextPath}/common/js/thickbox/thickbox.js"></script>
<script src="${rc.contextPath}/common/js/config.js"></script> --><!-- 
<script
	src="${rc.contextPath}/common/js/market/customer/customer_details.js"></script> -->


<script src="${rc.contextPath}/assets/js/flot/jquery.flot.min.js"></script>
<script src="${rc.contextPath}/assets/js/flot/jquery.flot.pie.min.js"></script>
<script src="${rc.contextPath}/assets/js/flot/jquery.flot.resize.min.js"></script>
<script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
<script src="${rc.contextPath}/assets/js/ace-elements.min.js"></script>
<script src="${rc.contextPath}/assets/js/ace.min.js"></script>
<script src="${rc.contextPath}/assets/js/bootbox.min.js"></script><!-- 
<script
	src="${rc.contextPath}/assets/js/date-time/daterangepicker.min.js"></script> --><!-- 
<script src="${rc.contextPath}/assets/js/jquery.validate.min.js"></script> -->
<script src="${rc.contextPath}/assets/js/date-time/moment.min.js"></script>
</head>

<body>
	<div class="main-container">
		<div class="page-content">

			<div class="page-header">
				当前位置 <i class="icon-double-angle-right"></i> 客户管理 <small> <i
					class="icon-double-angle-right"></i> 客户状态变更查询
				</small>
				<p style="float: right">姓名： $!{currentUser.ename}</p>
			</div>

			<form class="form-horizontal" id="validation-form" method="post"
				action="${rc.contextPath}/allot/findAllotRecord"
				>
				<div class="form-group">
					<label class="control-label col-sm-1 col-sm-offset-3" for="agentCode">会员号:</label>
					<div class="col-sm-2">
						<div class="clearfix">
							<input type="text" name="cusId" id="agentCode"
								class="form-control input-sm"  />
						</div>
					</div>
					<div class="col-sm-offset-7">
						<button type="button" class="btn btn-danger" id="queryButton" style="height:28px;padding-top:4px;">查询</button>
					</div>
				</div>

			</form>
			<div id="dialog" class="hide"></div>
			<hr />
			<table id="grid-table"></table>

			<div id="grid-pager"></div>
		</div>
	</div>
	<script type="text/javascript">
		try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
	</script>
	<script type="text/javascript">
		//格式化客户类型
		function actionCustomerType( cellvalue, options, rowObject ){
			switch(cellvalue)
			{
			case 1:
			  return '新注册客户';
			  break;
			  
			case 3:
			  return '意向客户';
			  break;
			case 5:
				  return '待续费客户';
				  break;
			case 4:
				  return '服务期客户';
				  break;
			case 7:
				  return '报备客户';
				  break;
			case 12:
				  return '保护期客户';
				  break;
			case 6:
				  return '公海客户';
				  break;
			default:
				return '未知';
			}
		}
	
		var grid_selector = "#grid-table";
		var pager_selector = "#grid-pager";
		var column = '["会员号","操作时间","客户类型","操作人"]';
		var columnCode = [{"name":"customId","width":30}, 
		                  {"name":"startTime","width":60}, 
		                  {"name":"customType","width":40,"formatter" : actionCustomerType}, 
		                  {"name":"ename","width":30}];
		var url = "${rc.contextPath}/allot/getCustomerStateHistory";
		column = jQuery.parseJSON(column);
		postData = jQuery.parseJSON('{"cusId":"hy110"}');
		$("#queryButton").click(function() {
			var agentCode=$("#agentCode").val();
			/* var company=$("#company").val();
			var operateTime=$("#id-date-range-picker-1").val(); */
            $(grid_selector).jqGrid('setGridParam',{
            	postData:{"cusId":agentCode},
            	page:0,
            	rows:20
        	}).trigger('reloadGrid'); 
		});
		/* $('input[name=operateTime]').daterangepicker(
				{
					format:'YYYY-MM-DD',
					separator : ' 到 ',
					language:"cn",
					 dateLimit : {
                        days : 30
                    },  //起止时间的最大间隔
                    ranges : {
                        //'最近1小时': [moment().subtract('hours',1), moment()],
                        '今日': [moment().startOf('day'), moment()],
                        '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
                        '最近7日': [moment().subtract('days', 6), moment()],
                        '最近30日': [moment().subtract('days', 29), moment()]
                    },
                    opens : 'right', //日期选择框的弹出位置
                    locale : {
                        applyLabel : '确定',
                        cancelLabel : '取消',
                        fromLabel : '起始时间',
                        toLabel : '结束时间',
                        customRangeLabel : '选择时间',
                        daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                        monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',
                            '七月', '八月', '九月', '十月', '十一月', '十二月' ],
                        firstDay : 1
                    }
				}
		).prev().on(ace.click_event, function(){
			$(this).next().focus();
		});  */
		/* 	
		function pickDate( cellvalue, options, cell ) {
			setTimeout(function(){
				$(cell) .find('input[type=text]')
						.datepicker({format:'yyyy-mm-dd' , autoclose:true}); 
			}, 0);
		} */
		
		//replace icons with FontAwesome icons like above
		function updatePagerIcons(table) {
			var replacement = 
			{
				'ui-icon-seek-first' : 'icon-double-angle-left bigger-140',
				'ui-icon-seek-prev' : 'icon-angle-left bigger-140',
				'ui-icon-seek-next' : 'icon-angle-right bigger-140',
				'ui-icon-seek-end' : 'icon-double-angle-right bigger-140'
			};
			$('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
		}
		
		function enableTooltips(table) {
			$('.navtable .ui-pg-button').tooltip({container:'body'});
			$(table).find('.ui-pg-div').tooltip({container:'body'});
		}
	
		function enableTooltips(table) {
			$('.navtable .ui-pg-button').tooltip({container:'body'});
			$(table).find('.ui-pg-div').tooltip({container:'body'});
		}
		
		function makegrid(postData){
			jQuery(grid_selector).jqGrid({
				url : url,
				
				mtype : "POST",
				contentType : "application/json",
				datatype : "json",
				height: 350,
				autowidth:true,
				colNames:column,
				colModel:columnCode,
				rowNum:20,
				viewrecords : true,
				rowList:[20],
				pager : pager_selector,
				emptyrecords: "没有查到相关数据！", 
				pgtext : "第{0}页，总共{1}页", 
				recordtext : "查看 {0} - {1}条记录， 总记录数 {2}",
				loadtext:"加载中，请稍候...",
				altRows: true,
				jsonReader : {
				      root:"records",
				      page: "pageNow", //当前页
				      total: "pageCount", //总页数
				      records: "rowCount"//总记录数
				},
				 loadComplete : function() {
					 var table = this;
						var re_records = $(grid_selector).getGridParam('records');
						if(re_records == 0 || re_records == null){
							$(grid_selector).setGridHeight(0);
						} if(re_records < 10){
							$(grid_selector).setGridHeight(re_records*35);
						} 
						else {
							$(grid_selector).setGridHeight(642);
						}
						$("#id").setGridWidth($(window).width()*0.98);　
						setTimeout(function(){
							updatePagerIcons(table);
						}, 0);
				},
			});
		}
		
		makegrid(postData);
		
	</script>
</body>
</html>
